// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

{namespace e2e.ext.ui.templates.panels.prompt}


/**
 * Renders the required UI elements for a generic PGP action (e.g. decryption, key import).
 */
{template .renderGenericForm}
  {@param textAreaPlaceholder: ?}  /** The placeholder text that will be displayed in the textarea.
      */
  {@param actionButtonTitle: ?}  /** The title of the prompt button. */
  {@param cancelButtonTitle: ?}  /** The title of the cancel button. */
  <textarea placeholder="{$textAreaPlaceholder}"></textarea>
  <div class="{e2e.ext.constants.CssClass.PROMPT_ACTIONS}">
    <button class="{e2e.ext.constants.CssClass.ACTION}">{$actionButtonTitle}</button>
    <button class="{e2e.ext.constants.CssClass.CANCEL}">{$cancelButtonTitle}</button>
  </div>
{/template}


/**
 * Renders the required UI elements for PGP encryption.
 */
{template .renderEncrypt}
  {@param insertCheckboxEnabled: ?}  /** A boolean flag if the insert checkbox should be displayed.
      */
  {@param canSaveDraft: ?}  /** A boolean flag if the save draft feature should be enabled. */
  {@param fromLabel: ?}  /** The label to describe the "From:" select box. */
  {@param signerCheckboxTitle: ?}  /** The label for the checkbox to sign messages. */
  {@param actionButtonTitle: ?}  /** The title of the prompt button. */
  {@param saveDraftButtonTitle: ?}  /** The title of the save button. */
  {@param insertButtonTitle: ?}  /** The title of the insert button. */
  {@param cancelButtonTitle: ?}  /** The title of the cancel button. */
  {@param subject: ?}  /** The value of the subject field if applicable. */
  {@param subjectLabel: ?}  /** The label to describe the "Subject:" box if applicable. */
  {@param origin: ?}  /** Origin of the content. */
  <div id="{e2e.ext.constants.ElementId.FROM_HOLDER}">
    <div>{$fromLabel}</div>
    <select id="{e2e.ext.constants.ElementId.SIGNER_SELECT}"></select>
  </div>
  <div id="{e2e.ext.constants.ElementId.CHIP_HOLDER}"></div>
  {if isNonnull($subject)}
  <div id="{e2e.ext.constants.ElementId.SUBJECT_HOLDER}">
    <div>{$subjectLabel}</div>
      <input id="{e2e.ext.constants.ElementId.SUBJECT}" value="{$subject}" />
  </div>
  {/if}
  <textarea data-origin="{$origin}"></textarea>
  <div class="{e2e.ext.constants.CssClass.PROMPT_ACTIONS}">
    <div>
      <input type="checkbox" id="{e2e.ext.constants.ElementId.SIGN_MESSAGE_CHECK}">
      <label for="{e2e.ext.constants.ElementId.SIGN_MESSAGE_CHECK}">
        {$signerCheckboxTitle}
      </label>
    </div>
    <button class="{e2e.ext.constants.CssClass.ACTION}">{$actionButtonTitle}</button>
    {if $insertCheckboxEnabled}
      <button class="{e2e.ext.constants.CssClass.INSERT}{sp}
                     {e2e.ext.constants.CssClass.HIDDEN}">
        {$insertButtonTitle}
      </button>
    {/if}
    {if $canSaveDraft}
      <button class="{e2e.ext.constants.CssClass.SAVE}">{$saveDraftButtonTitle}</button>
    {/if}
    <button class="{e2e.ext.constants.CssClass.CANCEL}">{$cancelButtonTitle}</button>
  </div>
{/template}
